import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {IndexComponent} from './index/index.component';
import {JoinRosterComponent} from './join-roster/join-roster.component';
import {AppComponent} from './app.component';
import {RosterComponent} from './roster/roster.component';
import {RosterInfoComponent} from './roster-info/roster-info.component';
//路由守卫
import{EnterGuard} from './my-guard/enter.guard';

export const routes: Routes = [
  {path: 'home', component: AppComponent,children:[
      {path:'enter/:id',component:JoinRosterComponent,canActivate: [EnterGuard]},
      {path:'index',component:IndexComponent},
      {path:'roster',component:RosterComponent,canActivate: [EnterGuard]},
      {path:'rosterInfo/:id',component:RosterInfoComponent,canActivate: [EnterGuard]},
      { path: '', redirectTo: 'index', pathMatch: 'full' },
    ]},
  { path: '', redirectTo: 'home', pathMatch: 'full' }

];


@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers:[
    EnterGuard
  ]
})
export class AppRoutingModule { }
